import 'package:flutter/cupertino.dart';

class AMCategoryModel {

  String id;
  String title;
  String color;
  Color cColor;

  AMCategoryModel({this.id,this.title,this.color});

  AMCategoryModel.fromJson(Map<String,dynamic> json) {
    id = json['id'];
    title = json['title'];
    color = json['color'];

    // 1.将color转成十六进制数字
    final colorInt = int.parse(color, radix: 16);
    // 2.将透明度加进去
    cColor = Color(colorInt | 0xFF000000);
  }


  Map<String, dynamic> toJson() => {
    "id": id,
    "title": title,
    "color": color,
  };
}
